<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>回收站 - 便签系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css" rel="stylesheet">
    <link href="/css/custom.css" rel="stylesheet">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark">
        <div class="container">
            <a class="navbar-brand" href="/memo/list">
                <i class="bi bi-sticky me-2"></i>便签系统
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/memo/list">
                            <i class="bi bi-collection me-1"></i>我的便签
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/memo/add">
                            <i class="bi bi-plus-circle me-1"></i>添加便签
                        </a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="categoriesDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                            <i class="bi bi-tag me-1"></i>分类管理
                        </a>
                        <ul class="dropdown-menu" aria-labelledby="categoriesDropdown">
                            <li><a class="dropdown-item" href="/category/list"><i class="bi bi-list-ul me-1"></i>查看分类</a></li>
                            <li><a class="dropdown-item" href="/category/add"><i class="bi bi-plus-lg me-1"></i>添加分类</a></li>
                        </ul>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link active" href="/memo/recycle-bin">
                            <i class="bi bi-trash me-1"></i>回收站
                        </a>
                    </li>
                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="/logout">
                            <i class="bi bi-box-arrow-right me-1"></i>退出登录
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        <div class="row mb-4">
            <div class="col">
                <h2 class="mb-0">
                    <i class="bi bi-trash me-2"></i>回收站
                </h2>
                <p class="text-muted">这里存放您删除的便签，30天后将自动清除</p>
            </div>
            <div class="col-auto align-self-center">
                <button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#emptyTrashModal">
                    <i class="bi bi-trash-fill me-1"></i>清空回收站
                </button>
            </div>
        </div>

        <div class="alert alert-info fade-in" th:if="${#lists.isEmpty(trashedMemos)}">
            <i class="bi bi-info-circle me-2"></i>
            <span>回收站中没有便签</span>
        </div>

        <div class="row" th:unless="${#lists.isEmpty(trashedMemos)}">
            <div class="col-md-6 col-lg-4 mb-4" th:each="memo : ${trashedMemos}">
                <div class="card h-100 fade-in note-card">
                    <div class="card-header d-flex justify-content-between align-items-center">
                        <h5 class="card-title mb-0" th:text="${memo.title}">便签标题</h5>
                        <span th:if="${memo.category != null}" class="badge" th:style="'background-color: ' + ${memo.category.color} + ';'" th:text="${memo.category.name}">分类名称</span>
                    </div>
                    <div class="card-body">
                        <p class="card-text" th:text="${#strings.abbreviate(memo.content, 100)}">便签内容...</p>
                    </div>
                    <div class="card-footer d-flex justify-content-between align-items-center">
                        <small class="text-muted">
                            <i class="bi bi-clock me-1"></i>
                            <span th:text="${#dates.format(memo.deleteTime, 'yyyy-MM-dd HH:mm')}">删除时间</span>
                        </small>
                        <div class="btn-group">
                            <a th:href="@{/memo/restore/{id}(id=${memo.id})}" class="btn btn-sm btn-outline-primary" title="恢复">
                                <i class="bi bi-arrow-counterclockwise"></i>
                            </a>
                            <a th:href="@{/memo/delete-permanently/{id}(id=${memo.id})}" class="btn btn-sm btn-outline-danger" 
                               onclick="return confirm('确定要永久删除这条便签吗？此操作无法撤销！')" title="永久删除">
                                <i class="bi bi-x-circle"></i>
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 清空回收站确认模态框 -->
    <div class="modal fade" id="emptyTrashModal" tabindex="-1" aria-labelledby="emptyTrashModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="emptyTrashModalLabel">确认清空回收站</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <p>确定要清空回收站吗？此操作将永久删除回收站中的所有便签，且无法撤销！</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <a href="/memo/empty-trash" class="btn btn-danger">确认清空</a>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html> 